<?php
namespace Health\Http\Controllers\Admin;

use Health\Http\Controllers\Admin\BaseController;
use Illuminate\Http\Request;
use Health\Models\Admin;
use Auth;

class AuthController extends BaseController
{
    public function login(Request $request)
    {
        if($request->input('type')=='logout'){
            Auth::logout();
        }
        return view('admin.login');

    }

    public function postLogin(Request $request){
        $data=array_map('trim', $request->except(['_url', '_']));
        if(Auth::attempt($data)){
            Admin::updateLoginInfo(self::getIp($request));
            return redirect()->away('/');
        }else{
            echo '账号密码错误';
        }
    }
}